/**
 * Copyright (C), 2021-2023, 四信物联网有限公司
 * FileName: BDicpMessageHandler
 * Author:   Chapin
 * Date:     2023/10/20 17:53
 * Description: ICP消息处理
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.fourfaith.iot.beidou.handler;

import com.fourfaith.iot.beidou.decodec.BeiDouContants;
import com.fourfaith.iot.beidou.message.inbound.BDpwiMessage;
import com.fourfaith.iot.beidou.session.SessionFactory;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 〈PWI消息处理〉
 * @author Chapin
 * @create 2023/10/20
 * @since 1.0.0
 */
@ChannelHandler.Sharable
public class BDpwiMessageHandler extends SimpleChannelInboundHandler<BDpwiMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, BDpwiMessage msg) throws Exception {
        Channel channel = ctx.channel();
        SessionFactory.getSession().bind(channel,BeiDouContants.BEI_DOU3);
        //保存信号属性
        SessionFactory.getSession().setAttribute(ctx.channel(), BeiDouContants.BDPWI, msg);
    }
}